import { SET_TOKEN, CLEAR_TOKEN, SET_CURRENTFULLPATH, CLEAR_CURRENTFULLPATH } from 'store/mutations_type';

export default {
    SetToken(context, token) {
        return new Promise((resolve,reject) => {
            if(context.state.token !== '') {
                // console.log('已经有token了：',token);
                reject();
            } else {
                // console.log('将token值设置为:',token);
                context.commit(SET_TOKEN,token);
                resolve();
            }
        })
    },

    ClearToken(context) {
        return new Promise((resolve,reject) => {
            context.commit(CLEAR_TOKEN);
            resolve();
        })
    },

    SetCurrentFullPath(context,fullpath) {
        return new Promise((resolve, reject) => {
            context.commit(SET_CURRENTFULLPATH, fullpath)
            resolve()
        })
    },

    ClearCurrentFullPath(context) {
        return new Promise((resolve, reject) => {
            context.commit(CLEAR_CURRENTFULLPATH)
            resolve()
        })
    }
}